{% extends "base.html" %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h2 class="h2">薪资预测</h2>
</div>

<div class="card mb-4">
    <div class="card-body">
        <h5 class="card-title">薪资预测模型</h5>
        <p class="card-text">基于机器学习算法对岗位薪资进行预测</p>
        <div class="alert alert-info">
            <i class="fas fa-info-circle me-2"></i>
            模型状态:
            <strong class="{% if model_status == '已加载' %}text-success{% else %}text-warning{% endif %}">
                {{ model_status }}
            </strong>
            <br>
            <small>模型路径: {{ model_path }}</small>
            {% if model_status == "未加载" %}
            <br><small class="text-warning">
                <i class="fas fa-exclamation-triangle me-1"></i>
                请先运行 train_model.py 训练模型
            </small>
            {% endif %}
        </div>
        <form method="GET" class="row g-3">
            <div class="col-md-6">
                <label for="city" class="form-label">城市</label>
                <input type="text" class="form-control" id="city" name="city" value="{{ request.args.get('city', '北京') }}" required>
            </div>
            <div class="col-md-6">
                <label for="industry" class="form-label">行业</label>
                <input type="text" class="form-control" id="industry" name="industry" value="{{ request.args.get('industry', '互联网') }}" required>
            </div>
            <div class="col-md-6">
                <label for="education" class="form-label">学历要求</label>
                <select class="form-select" id="education" name="education" required>
                    <option value="大专" {% if request.args.get('education') == '大专' %}selected{% endif %}>大专</option>
                    <option value="本科" {% if request.args.get('education') == '本科' or not request.args.get('education') %}selected{% endif %}>本科</option>
                    <option value="硕士" {% if request.args.get('education') == '硕士' %}selected{% endif %}>硕士</option>
                    <option value="博士" {% if request.args.get('education') == '博士' %}selected{% endif %}>博士</option>
                </select>
            </div>
            <div class="col-md-6">
                <label for="experience" class="form-label">工作经验</label>
                <select class="form-select" id="experience" name="experience" required>
                    <option value="应届生" {% if request.args.get('experience') == '应届生' %}selected{% endif %}>应届生</option>
                    <option value="1-3年" {% if request.args.get('experience') == '1-3年' or not request.args.get('experience') %}selected{% endif %}>1-3年</option>
                    <option value="3-5年" {% if request.args.get('experience') == '3-5年' %}selected{% endif %}>3-5年</option>
                    <option value="5-10年" {% if request.args.get('experience') == '5-10年' %}selected{% endif %}>5-10年</option>
                    <option value="10年以上" {% if request.args.get('experience') == '10年以上' %}selected{% endif %}>10年以上</option>
                </select>
            </div>
            <div class="col-md-6">
                <label for="company_size" class="form-label">公司规模</label>
                <select class="form-select" id="company_size" name="company_size" required>
                    <option value="0-20人" {% if request.args.get('company_size') == '0-20人' %}selected{% endif %}>0-20人</option>
                    <option value="20-99人" {% if request.args.get('company_size') == '20-99人' %}selected{% endif %}>20-99人</option>
                    <option value="100-500人" {% if request.args.get('company_size') == '100-500人' or not request.args.get('company_size') %}selected{% endif %}>100-500人</option>
                    <option value="500-1000人" {% if request.args.get('company_size') == '500-1000人' %}selected{% endif %}>500-1000人</option>
                    <option value="1000人以上" {% if request.args.get('company_size') == '1000人以上' %}selected{% endif %}>1000人以上</option>
                </select>
            </div>
            <div class="col-12">
                <button type="submit" class="btn btn-primary">预测薪资</button>
            </div>
        </form>

        {% if prediction %}
        <div class="alert alert-success mt-4">
            <h6>预测结果：</h6>
            <p class="mb-0">根据您选择的参数，预测薪资为：<strong>{{ prediction }}</strong></p>
        </div>
        {% endif %}
    </div>
</div>

<div class="card">
    <div class="card-body">
        <h5 class="card-title">模型说明</h5>
        <ul>
            <li>使用线性回归模型进行薪资预测</li>
            <li>特征包括：城市、行业、学历、工作经验、公司规模</li>
            <li>模型基于BOSS招聘数据进行训练</li>
            <li>预测结果为月薪（单位：k）</li>
        </ul>
    </div>
</div>
{% endblock %}